#include "gtest/gtest.h"

#include "util/coding.h"

TEST(CodingTest, use){
  std::string dst;
  rocksdb::PutFixed16(&dst, 0x1ff);
  std::cout << dst.size() << std::endl;
}


#include "rocksdb/file_system.h"
#include "file/writable_file_writer.h"
#include "db/log_writer.h"




TEST(LogWriterTest, use){
  using namespace rocksdb;


  auto && f = [](auto & fs, const auto & log_fname ) -> std::unique_ptr<log::Writer>{
    FileOptions fopt;

    std::unique_ptr<FSWritableFile> file;
    auto && st = fs->NewWritableFile(log_fname, fopt, &file, nullptr);
    if(!st.ok()){
      return nullptr;
    }
    
    auto && file_writer = std::make_unique<WritableFileWriter>(std::move(file), log_fname, fopt);
    return std::make_unique<log::Writer>(std::move(file_writer), 1, false);
  };

  const std::string log_fname = "hello.log";
  auto && log = f(Env::Default()->GetFileSystem(), log_fname);

  /*  
  std::unique_ptr<FSWritableFile> file;
  FileOptions fopt;
  ASSERT_TRUE(Env::Default()->GetFileSystem()->NewWritableFile(log_file_name, fopt, &file, nullptr).ok());
  ASSERT_TRUE(file != nullptr);

  std::unique_ptr<WritableFileWriter> file_writer(new WritableFileWriter(std::move(file),  log_file_name, fopt));

  //new log::Writer 
  std::unique_ptr<log::Writer> log(new log::Writer(std::move(file_writer), 1,  false));

  */
  ASSERT_TRUE(log != nullptr);
  log->AddRecord("wowoowowowowo");
}


//TODO: 
TEST(CurrentTest, use){
}
